package com.ruoyi.jkcrData.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jkcrData.domain.pad.JkcrTaskReqDTO;
import com.ruoyi.jkcrData.domain.report.JkcrReportData;
import com.ruoyi.jkcrData.service.IDataJkcrService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.ExecutionException;

/**
 * 架空乘人-测试Controller
 * 
 * @author lgq
 * @date 2023-1-2
 */
@RestController
@RequestMapping("/jkcrData/all")
@Api(value="架空乘人-测试",tags = "架空乘人-测试接口")
public class DataJkcrController extends BaseController
{

    @Autowired
    public IDataJkcrService dataJkcrService;



    /**
     * 查询此架空乘人任务的所有测试项目数据
     */
    @PreAuthorize("@ss.hasPermi('jkcrData:task:query')")
    @GetMapping("/{dataTaskId}")
    @ApiOperation(value="查询此架空乘人任务的所有测试项目数据")
    @ApiImplicitParam(paramType="query", name = "dataTaskId", value = "任务id", required = true, dataType = "Long")
    public AjaxResult getDetailJkcr(@PathVariable("dataTaskId") Long dataTaskId) throws InterruptedException, ExecutionException {
        JkcrTaskReqDTO jkcrTaskReqDTO = dataJkcrService.getDetailJkcr(dataTaskId);
        return AjaxResult.success(jkcrTaskReqDTO);
    }

    /**
     * 根据任务id删除整条架空乘人测试结果
     */
    @PreAuthorize("@ss.hasPermi('jkcrData:task:remove')")
    @Log(title = "根据任务id删除整条架空乘人测试结果", businessType = BusinessType.DELETE)
    @DeleteMapping("/updateDataJkcrByDataTaskId/{dataTaskId}")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "dataTaskId", value = "任务id", required = true, dataType = "Long"),
    })
    @ApiOperation(value="根据任务id删除整条单轨吊测试结果")
    public AjaxResult updateDataDgdByDataTaskId(@PathVariable("dataTaskId")Long dataTaskId)
    {
        return toAjax(dataJkcrService.delAllJkcrData(dataTaskId));
    }

    /**
     * 保存的架空乘人数据导入报告
     */
    @PreAuthorize("@ss.hasPermi('jkcrData:import:query')")
    @PostMapping("/dataJkcrImportReport")
    @ApiOperation(value="保存的架空乘人数据导入报告")
    public AjaxResult dataJkcrImportReport(@ApiParam(name="测试项目结果数据",value="传入json格式",required=true)@RequestBody JkcrReportData jkcrReportData){
        return AjaxResult.success(dataJkcrService.dataJkcrImportReport(jkcrReportData));
    }
}
